<template>
  <div class="container">
    <h1 id="txt">{{ t }}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
      t: "",
    };
  },
  created() {
    setInterval(this.fn, 1000);
  },
  methods: {
    fn() {
      this.$options.methods.bl.bind(this)();
      var now = new Date() * 1;
      var nox = new Date("2022-05-01 0:0:0:") * 1;
      var cha = nox - now;
      var t = 24 * 60 * 60 * 1000;
      var h = 60 * 60 * 1000;
      var f = 60 * 1000;
      var tt = Math.floor(cha / t);
      var hh = Math.floor((cha % t) / h);
      var ff = Math.floor((cha % h) / f);
      var ss = Math.floor((cha % f) / 1000);
      this.t = `距离五一劳动节还有${tt}天${this.$options.methods.bl.bind()(
        ff
      )}小时${this.$options.methods.bl.bind()(
        hh
      )}分钟${this.$options.methods.bl.bind()(ss)}秒`;
    },
    bl(z) {
      return z < 10 ? "0" + z : z;
    },
  },
  components: {},
};
</script>

<style scoped></style>
